﻿@using Telerik.Web.Mvc.UI;
@using Telerik.Web.Mvc;
@using Uco.Infrastructure;

@{
    if (!Telerik.Web.Mvc.SiteMapManager.SiteMaps.ContainsKey("admin"))
    {
        Telerik.Web.Mvc.SiteMapManager.SiteMaps.Register<Telerik.Web.Mvc.XmlSiteMap>("admin", sitemap => sitemap.LoadFrom("~/Areas/Admin/sitemap.xml"));
    }
}
@(Html.Telerik().Menu()
    .Name("menu")
    .BindTo("admin", (item, siteMapNode) =>
    {
        var imageUrl = ((Telerik.Web.Mvc.SiteMapNode)siteMapNode).Attributes["ImageUrl"];
        if (imageUrl != null && !string.IsNullOrEmpty(imageUrl.ToString()))
        {
            item.ImageUrl = imageUrl.ToString();
        }

        var resourceName = ((Telerik.Web.Mvc.SiteMapNode)siteMapNode).Attributes["Resource"];
        var resourceLocalName = Html.R(VirtualPath, resourceName.ToString());
        if (resourceLocalName != "")
        {
            item.Text = Html.R(VirtualPath, resourceName.ToString());
        }

        if (ViewBag.SelectedMenuItem == item.Text)
        {
            item.Selected = true;
        }
    })
    .HtmlAttributes(new { style = "position: relative; z-index: 100" })
)
